using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace ProtectThePie
{
    public static class Vector2Add
    {
        public static void Add(ref Vector2 vector, Vector2 toAdd)
        {
            vector.X += toAdd.X;
            vector.Y += toAdd.Y;
        }

        public static void Add(ref Vector2 vector, float X, float Y)
        {
            vector.X += X;
            vector.Y += Y;
        }

        public static float ToAngle(Vector2 vector)
        {
            return (float)(Math.Atan2(vector.Y, vector.X));
        }

        public static void GoToVector2(ref Vector2 speed, Vector2 position, Vector2 destination, float magnitude)
        {
            FindVector2(ref speed, ToAngle(new Vector2(destination.X - position.X, destination.Y - position.Y)), magnitude);
        }

        public static void FindVector2(ref Vector2 vector, float angle, float magnitude)
        {
            vector.X = (float)(magnitude * Math.Cos(angle));
            vector.Y = (float)(magnitude * Math.Sin(angle));
        }

        public static void RedirectToAngle(ref Vector2 speed, float angle)
        {
            float vLenght = speed.Length();

            speed.Y = (float)Math.Sin(angle) * vLenght;
            speed.X = (float)Math.Cos(angle) * vLenght;
        }

        public static Microsoft.Xna.Framework.Point Vector2ToPoint(Vector2 vector)
        {
            return new Microsoft.Xna.Framework.Point((int)vector.X, (int)vector.Y);
        }
    }
}
